<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>自有车辆管理</title>
	<meta name="decorator" content="ani"/>
	<script type="text/javascript">
		var validateForm;
		var $table; // 父页面table表格id
		var $topIndex;//弹出窗口的 index
		function doSubmit(table, index){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $table = table;
			  $topIndex = index;
			  jp.loading();
			  $("#inputForm").submit();
			  return true;
		  }

		  return false;
		}

		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					jp.post("${ctx}/fleet/vehicleInformation/save",$('#inputForm').serialize(),function(data){
						if(data.success){
	                    	$table.bootstrapTable('refresh');
	                    	jp.success(data.msg);
	                    	jp.close($topIndex);//关闭dialog

	                    }else{
            	  			jp.error(data.msg);
	                    }
					})
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
	        $('#purchaseDate').datetimepicker({
				 format: "YYYY-MM-DD"
		    });
	        $('#annualDate').datetimepicker({
                format: "YYYY-MM-DD"
		    });
	        $('#servicingTime').datetimepicker({
                format: "YYYY-MM-DD"
		    });
	        $('#discardTime').datetimepicker({
                format: "YYYY-MM-DD"
		    });
            $('#njsx').datetimepicker({
                format: "YYYY-MM-DD"
            });
	        $('#effectiveDate').datetimepicker({
                format: "YYYY-MM-DD"
		    });
	        $('#expiryDate').datetimepicker({
                format: "YYYY-MM-DD"
		    });
		});
		
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
			$(list+idx).find(".form_datetime").each(function(){
				 $(this).datetimepicker({
					 format: "YYYY-MM-DD HH:mm:ss"
			    });
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body class="bg-white">
		<form:form id="inputForm" modelAttribute="vehicleInformation" action="${ctx}/fleet/vehicleInformation/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<table class="table table-bordered">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right"><span style="color: red">*</span>车队：</label></td>
					<td class="width-35">
						<sys:gridselect url="${ctx}/fleet/motorcade/data" id="motorcade" name="motorcade.id" value="${vehicleInformation.motorcade.id}" labelName="motorcade.name" labelValue="${vehicleInformation.motorcade.name}"
							 title="选择车队" cssClass="form-control required" fieldLabels="名称" fieldKeys="name" searchLabels="名称" searchKeys="name" ></sys:gridselect>
					</td>
					<td class="width-15 active"><label class="pull-right"><span style="color: red">*</span>车牌号：</label></td>
					<td class="width-35">
						<form:input path="license" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">行驶证号：</label></td>
					<td class="width-35">
						<form:input path="travelId" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">档案编号：</label></td>
					<td class="width-35">
						<form:input path="archivesNumber" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">排放标准：</label></td>
					<td class="width-35">
						<form:input path="emissionStandard" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">发动机号：</label></td>
					<td class="width-35">
						<form:input path="engineNumber" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">车架号：</label></td>
					<td class="width-35">
						<form:input path="frameNumber" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">总质量：</label></td>
					<td class="width-35">
						<form:input path="totalMass" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">整备质量：</label></td>
					<td class="width-35">
						<form:input path="curbWeight" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">核定载质量：</label></td>
					<td class="width-35">
						<form:input path="approvedQuality" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">车轴数：</label></td>
					<td class="width-35">
						<form:input path="axleNumber" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">车辆品牌：</label></td>
					<td class="width-35">
						<form:input path="vehicleBrand" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">车辆型号：</label></td>
					<td class="width-35">
						<form:input path="carType" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">车型：</label></td>
					<td class="width-35">
						<form:input path="vehicleType" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">外形尺寸（长*宽*高）：</label></td>
					<td class="width-35">
						<form:input path="overallDimensions" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">单位：</label></td>
					<td class="width-35">
						<form:input path="unit" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">采购日期：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='purchaseDate'>
			                    <input type='text'  name="purchaseDate" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.purchaseDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
					<td class="width-15 active"><label class="pull-right">年检生效时间：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='annualDate'>
			                    <input type='text'  name="annualDate" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.annualDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">年检失效日期：</label></td>
					<td class="width-35">
						<p class="input-group">
						<div class='input-group form_datetime' id='njsx'>
							<input type='text'  name="njsx" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.effectiveDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							<span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
						</div>
						</p>
					</td>
					<td class="width-15 active"><label class="pull-right">年检费用：</label></td>
					<td class="width-35">
						<form:input path="njfy" htmlEscape="false"    class="form-control "/>
					</td>

				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">二级维护时间：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='servicingTime'>
			                    <input type='text'  name="servicingTime" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.servicingTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
					<td class="width-15 active"><label class="pull-right">强制报废时间：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='discardTime'>
			                    <input type='text'  name="discardTime" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.discardTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">保险类型：</label></td>
					<td class="width-35">
						<form:input path="insuranceType" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">保险公司：</label></td>
					<td class="width-35">
						<form:input path="insuranceCompany" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">保险经纪人姓名电话：</label></td>
					<td class="width-35">
						<form:input path="namePhone" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">保险生效日期：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='effectiveDate'>
			                    <input type='text'  name="effectiveDate" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.effectiveDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">保险失效日期：</label></td>
					<td class="width-35">
						<p class="input-group">
							<div class='input-group form_datetime' id='expiryDate'>
			                    <input type='text'  name="expiryDate" class="form-control "  value="<fmt:formatDate value="${vehicleInformation.expiryDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
			                    <span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
			                </div>						            
			            </p>
					</td>
					<td class="width-15 active"><label class="pull-right">保险单号：</label></td>
					<td class="width-35">
						<form:input path="insuranceMark" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">保额：</label></td>
					<td class="width-35">
						<form:input path="coverage" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">保费：</label></td>
					<td class="width-35">
						<form:input path="premium" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">备注信息：</label></td>
					<td class="width-35">
						<form:input path="remarks" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"></td>
		   			<td class="width-35" ></td>
		  		</tr>
		 	</tbody>
		</table>

		</form:form>
</body>
</html>